import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import App from './App';

test('渲染初始计数和按钮', () => {
  render(<App />);
  expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent('Count: 0');
  expect(screen.getByRole('button', { name: /Increment/i })).toBeInTheDocument();
});

test('点击按钮后计数增加', async () => {
  render(<App />);
  const button = screen.getByRole('button', { name: /Increment/i });
  await userEvent.click(button);
  expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent('Count: 1');
});
